#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2018/3/13 15:00
# @Author  : Swper
# @Site    : 
# @File    : __init__.py.py
# @Software: PyCharm

from flask import Flask
from app.config import config
from app.exts import db
from app.admin.models import *


def create_app():
    app = Flask(__name__)
    app.config.from_object(config['test'])

    #导入模块admin,home
    from app.admin import admin as admin_blueprint
    from app.home import home as home_blueprint

    #注册上面定义的蓝本路由，不注册的话就无法使用了
    app.register_blueprint(home_blueprint)
    app.register_blueprint(admin_blueprint,url_prefix='/admin')
    db.init_app(app)
    return app